package Interfaz;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Button;
import org.eclipse.wb.swt.SWTResourceManager;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;


/**
 * CU015 - Modificar lugar de realización
 * @author 
 */
public class CU015 {

	protected Shell shlModificarLugar;
	private Text text;
	private Text text_1;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			CU015 window = new CU015();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		
		// Centrar ventana
		Monitor primary = display.getPrimaryMonitor();
		Rectangle bounds = primary.getBounds();
		Rectangle rect = shlModificarLugar.getBounds();
		int x = bounds.x + (bounds.width - rect.width) / 2;
		int y = bounds.y + (bounds.height - rect.height) / 2;	    
		shlModificarLugar.setLocation(x, y);
		
		text_1 = new Text(shlModificarLugar, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
		text_1.setBounds(10, 119, 302, 68);
		
		Label label = new Label(shlModificarLugar, SWT.NONE);
		label.setText("Deportes disponibles:");
		label.setBounds(10, 209, 122, 15);
		
		ScrolledComposite scrolledComposite = new ScrolledComposite(shlModificarLugar, SWT.BORDER | SWT.V_SCROLL);
		scrolledComposite.setExpandVertical(true);
		scrolledComposite.setExpandHorizontal(true);
		scrolledComposite.setAlwaysShowScrollBars(true);
		scrolledComposite.setBounds(10, 230, 122, 87);
		
		Composite composite = new Composite(scrolledComposite, SWT.NONE);
		
		Button button = new Button(composite, SWT.CHECK);
		button.setText("B\u00E1squet");
		button.setBounds(10, 10, 93, 16);
		
		Button button_1 = new Button(composite, SWT.CHECK);
		button_1.setText("F\u00FAtbol");
		button_1.setBounds(10, 35, 93, 16);
		
		Button button_2 = new Button(composite, SWT.CHECK);
		button_2.setText("Voley");
		button_2.setBounds(10, 60, 93, 16);
		scrolledComposite.setContent(composite);
		scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		scrolledComposite.setMinSize(new Point(103, 76));
		
		shlModificarLugar.open();
		shlModificarLugar.layout();
		while (!shlModificarLugar.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shlModificarLugar = new Shell(SWT.CLOSE | SWT.TITLE | SWT.MIN);
		shlModificarLugar.setSize(414, 415);
		shlModificarLugar.setText("Modificar lugar");
		
		Label label = new Label(shlModificarLugar, SWT.NONE);
		label.setText("Nombre lugar:");
		label.setBounds(10, 15, 77, 15);
		
		text = new Text(shlModificarLugar, SWT.BORDER);
		text.setBounds(93, 12, 219, 21);
		
		Label label_1 = new Label(shlModificarLugar, SWT.NONE);
		label_1.setText("C\u00F3digo:");
		label_1.setBounds(10, 55, 42, 15);
		
		Label lblDescripcin = new Label(shlModificarLugar, SWT.NONE);
		lblDescripcin.setText("Descripci\u00F3n:");
		lblDescripcin.setBounds(10, 95, 122, 15);
		
		Button btnGuardar = new Button(shlModificarLugar, SWT.NONE);
		btnGuardar.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				MessageBox messageBox =   new MessageBox(shlModificarLugar, SWT.OK | SWT.ICON_INFORMATION);
				messageBox.setMessage("La operaci�n a culminado con �xito");
				messageBox.open();
			}
		});
		btnGuardar.setText("Aceptar");
		btnGuardar.setBounds(148, 330, 108, 32);
		
		Button button_4 = new Button(shlModificarLugar, SWT.NONE);
		button_4.setText("Cancelar");
		button_4.setBounds(280, 330, 108, 32);
		
		Label lblNewLabel = new Label(shlModificarLugar, SWT.NONE);
		lblNewLabel.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
		lblNewLabel.setBounds(58, 55, 45, 15);
		lblNewLabel.setText("100735");

	}

}
